
import { Popconfirm } from 'antd'
import styles from './index.module.css'
// table-columns

export const createColumns = ({deleteStudent}) => [{
    title: '姓名',
    dataIndex: 'name',
},{
    title: '年龄',
    dataIndex: 'age',
    render: (value) => {
        let cls = styles['blue-color'];
        if(value <=20){
            cls = styles['green-color'];
        }
        return (
            <span className={cls}>{value}</span>
        )
    }
}, {
    title: '地址',
    dataIndex: 'address'
}, {
    title: '操作',
    dataIndex: 'action',
    render: (__value, record) => {
        const { id } = record || {};
        return (
            <Popconfirm
                title="确认要删除该学员吗?"
                onConfirm={()=>deleteStudent(id)}
                okText="Yes"
                cancelText="No"
            >
                <a>删除</a>
            </Popconfirm>
        )
    }
}]